<template>
  <div class="header">
    <van-icon name="arrow-left" @click="skipHome" />
    <p>团购详情</p>
    <div class="left">
      <i class="iconfont">
        <van-icon
          :name="flag ? 'star-o' : 'star'"
          @click="flag = !flag"
          :style="{ color: flag ? '#000' : '#fff' }"
        />
        <span>{{ flag ? '收藏' : '取消收藏' }}</span></i
      >
      <div class="menu">
        <van-popover
          v-model:show="showPopover"
          :actions="actions"
          placement="bottom-end"
          @select="onSelect"
        >
          <template #reference>
            <van-button type="primary">
              <van-icon name="bars" />
              <p>导航</p>
            </van-button>
          </template>
        </van-popover>
      </div>
    </div>
  </div>
</template>

<script setup>
import { reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
let flag = ref(true)
let showPopover = ref(false)
let actions = reactive([
  { text: '我的', id: 1 },
  { text: '首页', id: 2 }
])
const router = useRouter()
function skipHome() {
  router.push({ name: 'home' })
}
function onSelect(action) {
  if (action.id === 1) {
    router.push({ name: 'me' })
  } else {
    router.push({ name: 'home' })
  }
}
</script>

<style lang="scss" scoped>
@import '../../iconfont/iconfont.css';
.header {
  height: 0.5rem;
  background: #ffcc00;
  padding: 0 0.1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #000;
  .van-icon {
    width: 0.3rem;
    font-size: 0.3rem;
  }
  p {
    font-weight: 600;
    font-size: 0.16rem;
  }
}
.left {
  display: flex;
  height: 100%;
  align-items: center;
  .iconfont {
    display: flex;
    width: 0.55rem;
    margin-top: 0.05rem;
    flex-direction: column;
    align-items: center;
    text-align: center;
    .van-icon {
      font-size: 0.24rem;
      margin-bottom: 0.02rem;
      text-align: center;
    }
    span {
      font-size: 0.08rem;
    }
  }
  .menu {
    display: flex;
    color: #000;
    font-size: 0.22rem;
  }
}
.van-popover {
  display: flex;
  flex-direction: column;
  color: #000;
  font-size: 0.12rem;
  .van-icon {
    font-size: 0.28rem;
    margin-bottom: 0.05rem;
    color: #000;
  }
}
.van-button {
  color: #000;
  font-size: 0.1rem;
  background: rgba(0, 0, 0, 0);
  border: none;
  width: 0.3rem;
  margin-top: 0.05rem;
  .van-icon {
    font-size: 0.26rem;
  }
  p {
    font-size: 0.12rem;
  }
}
</style>
